GBML manual / Rooms

room_width

The current room’s width, in pixels.

Syntax

room_width() -> int

Returns

int

Description

The current room's width, in pixels - the same width the editor's Room Properties set. Useful for anything that needs to reason about the room's own bounds from code, such as a custom camera_bounds call or a spawn position computed as a fraction of the room's size, rather than a hard-coded number that would go stale if the room's size ever changed.

Positions in a room count from its top-left corner, so room_width() is also the x of the room's right edge, and room_width() / 2 is the x of the room's middle.

Example

var w = room_width();

Reads the active room's width into a local variable, ready to use in a bounds or placement calculation.

See also: room_height